#include <iostream>
#include <string>
using namespace std;
constexpr int MAXN = 100;
string s, t;
int dp[MAXN][MAXN];
void solve();

int main() {
    cin >> s >> t;
    solve();
    return 0;
}

// s[i] == s[j] dp[i + ][j + 1] = dp[i][j] + 1;
void solve() {
    for (int i = 0; i < s.length(); i++)
        for (int j = 0; j < t.length(); j++) {
            if (s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
            else dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
        }
    cout << dp[s.length()][t.length()] << endl;
}